<?php
$i = 0;
foreach($_POST as $key=>$value) {
	$id = $value;
    $i++;
}
if($i == 1){
    
    session_start();
    include 'db_con.php';
    
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    		<title>Tractors</title>
    		<link rel="stylesheet" type="text/css" href="style/style.css">
    	</head>
    	<body>';
        $query = "SELECT * FROM `tractor` where tractor_id = '".$id."'";
        $result = mysqli_query($db_con, $query);
        if(mysqli_num_rows($result) == 1){
            while($row = mysqli_fetch_assoc($result)){
        		echo '<div class="wrap">
        			<div class="inner_wrap">
        				<div class="header"></div>
        				<div class="left_menu">
                            <p><a href="formAddTractor.php">ADD</a></p>
            				<p><a href="#" id="formDeleteTractor" onclick="manageForm(\'formDeleteTractor\');"> DELETE </a></p>
            				<p><a href="#" id="formEditTractor" onclick="manageForm(\'formEditTractor\');"> EDIT </a></p>
                            <p><a href="bueTractor.php">BYE</a></p>
        				</div>
        				<div class="content">
        					<div class="wrap_table">
        						<form action="editTractor.php" method="post" enctype="multipart/form-data">
                                Picture(if edit) : <input type="file" name="file" id="file"/><br>
                                Name : <input type="text" name="name" value="'.$row['name'].'" /><br>
                                Price : <input type="text" name="price" value="'.$row['price'].'" /><br>
                                <input type="hidden" name="id" value="'.$id.'">
                                <input type="submit" name="submit" value="Edit">
                                </form>
        					</div>
        				</div>	
        			</div>		
        		</div>';
            }
        }else{
            header("Location: index.php");
        }
    	echo '</body>
    </html>';

}else{
    header("Location: index.php");
}
?>